package com.zhong.common.core.domain.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.IgnoreUpdate;
import com.gitee.sunchenbin.mybatis.actable.annotation.Index;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.zhong.common.core.domain.BaseEntity;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;

/**
 * 菜单权限表 sys_menu
 *
 * @author zhongzc
 */
@Data
@TableName("sys_menu")
@Table(comment = "菜单权限表", name = "sys_menu", isSimple = true)
public class SysMenu extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 菜单名称 */
    @NotBlank(message = "菜单名称不能为空")
    @Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
    @Column(comment = "菜单名称")
    private String menuName;

    /** 父菜单名称 */
    @Column(comment = "父菜单名称")
    private String parentName;

    /** 父菜单ID */
    @Column(comment = "父菜单ID")
    private String parentId;

    /** 显示顺序 */
    @NotNull(message = "显示顺序不能为空")
    @Column(comment = "显示顺序")
    private Integer orderNum;

    /** 路由地址 */
    @Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
    @Column(comment = "路由地址")
    private String path;

    /** 组件路径 */
    @Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
    @Column(comment = "组件路径")
    private String component;

    /** 路由参数 */
    @Column(comment = "路由参数")
    private String query;

    /** 是否为外链（0是 1否） */
    @Column(comment = "是否为外链（0是 1否）",type = MySqlTypeConstant.CHAR)
    private String isFrame;

    /** 是否缓存（0缓存 1不缓存） */
    @Column(comment = "是否缓存（0缓存 1不缓存）",type = MySqlTypeConstant.CHAR)
    private String isCache;

    /** 类型（M目录 C菜单 F按钮） */
    @NotBlank(message = "菜单类型不能为空")
    @Column(comment = "类型（M目录 C菜单 F按钮）",type = MySqlTypeConstant.CHAR)
    private String menuType;

    /** 显示状态（0显示 1隐藏） */
    @Column(comment = "显示状态（0显示 1隐藏）",type = MySqlTypeConstant.CHAR)
    private String visible;

    /** 菜单状态（0正常 1停用） */
    @Column(comment = "菜单状态（0正常 1停用）",type = MySqlTypeConstant.CHAR)
    private String status;

    /** 权限字符串 */
    @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
    @Column(comment = "权限字符串")
    private String perms;

    /** 菜单图标 */
    @Column(comment = "菜单图标")
    private String icon;

    /** 祖级列表 */
    @Index
    @Column(comment = "祖级ID列表",length = 1000)
    private String ancestors;

    /** 子菜单 */
    @IgnoreUpdate
    @TableField(exist = false)
    private List<SysMenu> children = new ArrayList<SysMenu>();
}
